package demo1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class Test {
    //用一个数组来存储花色
    public static final String SUIT[] = {"♠", " ♥","♣","♦"};

    public static List<Card>  buyCards(){
        //用顺序表来存储牌
        List<Card> cards = new ArrayList<>();
        for (int i = 0; i < SUIT.length; i++) {
            for (int j = 1; j < 13; j++) {
                Card card = new Card(j,SUIT[i]);
                cards.add(card);
            }
        }
        return cards;
    }


    //洗牌
    public static List<Card> shuffle(List<Card> cards){
        Random random = new Random();
        for (int i = cards.size() - 1; i > 0; i--) {
            int j = random.nextInt(i);
            Card tmp = cards.get(j);
            cards.set(j,cards.get(i));
            cards.set(i,tmp);
        }
        return  cards;
    }



    public static void main(String[] args) {
        List<Card> card = buyCards();
        shuffle(card);
        System.out.println(card);

        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hand = new ArrayList<>();


        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                hand.get(j).add(card.remove(0));
            }
        }

    }

}
